$(function () {
    $('#login').on('click', function (e) {
        e.preventDefault();
        let username = $('#username').val().trim();
        let password = $('#password').val().trim();

        $.post('http://localhost:8080/api/v1/admin/user/login', { username, password }, function (res) {
            if(res.code == 200) {
                localStorage.setItem('token', res.token);
                location.href = 'index.html';
            }else {
                alert('登录失败');
            }
        })
    })
})